package com.yby.dome4;

public class Taxi {
    static double price = 8.0;//价钱，初始定义为8元
    double distance;//路程数
    //有参构造
    public Taxi(double distance){
        this.distance = distance;
    }
    //收费方法
    public void toll(double distance){
        this.distance = distance;
        if (distance>2){
           price = 8 + ( distance-2)*1.5;
            System.out.println("你总共行驶了"+distance+",一共"+price+"元");
        }else {
            System.out.println("一共"+price);
            return;
        }
    }
}
